/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package studenttrack.entity;

import java.io.Serializable;
import java.util.ArrayList;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import stException.WrongOldPasswordException;

/**
 *
 * @author tg227
 */
@Entity
public class Staff implements StaffInterface {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String id;

    public String getEmailID() {
        return id;
    }

    public void setEmailID(String emailID) {
        this.id = emailID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Staff)) {
            return false;
        }
        Staff other = (Staff) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "studenttrack.entity.Staff[id=" + id + "]";
    }

    //end gen code

    private String name;
    private String roomNumber;
    private String phoneNumber;
    private String password; // do we need to encrypt this??
    private ArrayList<String> moduleList;
    private ArrayList<String> coordinatorModuleList;
    private ArrayList<String> tutees;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setPassword(String oldPass, String newPass) throws WrongOldPasswordException {
        if(oldPass.equals(password)){
            password = newPass;
        } else {
            throw new WrongOldPasswordException();
        }
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getRoomNumber() {
        return roomNumber;
    }

    public void setRoomNumber(String roomNumber) {
        this.roomNumber = roomNumber;
    }

    public String[] getCoordinatorModuleList() {
        String[] co = new String[coordinatorModuleList.size()];
        int i = 0;
        while(i < co.length){
            co[i] = coordinatorModuleList.get(i);
            i++;
        }
        return co;
    }

    public String[] getModuleList() {
        String[] mo = new String[moduleList.size()];
        int i = 0;
        while(i < mo.length){
            mo[i] = moduleList.get(i);
            i++;
        }
        return mo;
    }

    public String[] getTutees() {
        String[] tu = new String[tutees.size()];
        int i = 0;
        while(i < tu.length){
            tu[i] = tutees.get(i);
            i++;
        }
        return tu;
    }

    
    protected void addModule(String moduleCode, boolean coordinator){
        if (coordinator){
            coordinatorModuleList.add(moduleCode);
            moduleList.add(moduleCode);
        } else {
            moduleList.add(moduleCode);
        }
    }





}
